Minimize lock usage in InternalLoggerRegistry#3418
Conversation
It has been reported that holding a lock on `InternalLoggerRegistry` during the creation of a logger can cause performance loss and deadlocks. The logger constructor can trigger property lookups and other pluggable operations, we don't entirely control. The fix to #3252 only covered one of these cases. This change moves the instantiation of new `Logger`s outside the write lock. While in some cases, this will cause multiple instantiations of loggers with the same parameters, all such loggers are functionally equivalent. On the other hand, the change allows the creation of different loggers in parallel. Closes #3399
...j-core/src/main/java/org/apache/logging/log4j/core/util/internal/InternalLoggerRegistry.java
Outdated
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/util/internal/InternalLoggerRegistry.java
Outdated
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/util/internal/InternalLoggerRegistry.java
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/util/internal/InternalLoggerRegistry.java
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/util/internal/InternalLoggerRegistry.java
Outdated
Show resolved
Hide resolved
...j-core/src/main/java/org/apache/logging/log4j/core/util/internal/InternalLoggerRegistry.java
Show resolved
Hide resolved
|
Tried implementing a test1 where |
|
@vy, Thanks for merging this. Could you cherry-pick it to |
Co-authored-by: Volkan Yazıcı <[email protected]>
|
@ppkarwasz, ported to |
|
Thanks, I added it to the backlog #3161 |
|
I don't see anywhere in |
|
I think the entire We introduced it so |
It has been reported that holding a lock on
InternalLoggerRegistryduring the creation of a logger can cause performance loss and deadlocks. The logger constructor can trigger property lookups and other pluggable operations, we don't entirely control. The fix to #3252 only covered one of these cases.This change moves the instantiation of new
Loggers outside the write lock. While in some cases, this will cause multiple instantiations of loggers with the same parameters, all such loggers are functionally equivalent. On the other hand, the change allows the creation of different loggers in parallel.Closes #3399